package com;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by IntelliJ IDEA.
 * User: BGONZ8
 * Date: 9/23/11
 * Time: 4:24 PM
 * To change this template use File | Settings | File Templates.
 */
public class FeedService {
    private String dataDirLocation;
    private String progName;
    private String rubJobLocation;
    private String batchFile = "C:\\packages\\BNX\\Data\\execMerge.bat";
    private String sourceSystem = "GD";
    private String result = "";

    public FeedService()
    {

    }

    public FeedService(String rubJobLocation, String dataDirLocation, String progName)
    {
        this.dataDirLocation = dataDirLocation;
        this.progName = progName;
        this.rubJobLocation = rubJobLocation;
    }

    public String getResult() {
        return result;
    }


    public String getSourceSystem() {
        return sourceSystem;
    }

    public void setSourceSystem(String sourceSystem) {
        this.sourceSystem = sourceSystem;
    }

    public String getBatchFile() {
        return batchFile;
    }

    public void setBatchFile(String batchFile) {
        this.batchFile = batchFile;
    }

    public String getDataDirLocation() {
        return dataDirLocation;
    }

    public void setDataDirLocation(String dataDirLocation) {
        this.dataDirLocation = dataDirLocation;
    }

    public String getRubJobLocation() {
        return rubJobLocation;
    }

    public void setRubJobLocation(String rubJobLocation) {
        this.rubJobLocation = rubJobLocation;
    }

    public String getProgName() {
        return progName;
    }

    public void setProgName(String progName) {
        this.progName = progName;
    }

    public void runJob() throws Exception
    {
        String cmd = batchFile + " " + this.getSourceSystem();
        Runtime run = Runtime.getRuntime();
        Process pr = run.exec(cmd);
        BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
		String line = "";
		while ((line=buf.readLine())!=null) {
            result = result + line + "\n";
		}
    }
}
